<?php
declare (strict_types = 1);
namespace app\admin\validate\market;

use think\Validate;

/**
 * vip配置验证
 */
class VipConfig extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'          => 'require',
        'title'       => 'require|length:1,30|unique:vip_config',
        'days'        => 'require|gt:0',
        'give_credit' => 'egt:0',
        'give_days'   => 'egt:0',

    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '请输入名称',
        'title.length'  => '名称为1-30个字符',
        'title.unique'  => '名称已存在',
        'days'          => '天数必须大于0',
        'give_credit'   => '赠送积分为正整数',
        'give_days'     => '赠送天数为正整数',
        'id'            => '操作出错',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create' => ['title', 'days', 'give_credit', 'give_days'],
        'edit'   => ['id', 'title', 'days', 'give_credit', 'give_days'],
    ];

}
